#!/usr/bin/perl

use warnings;
use strict;
use RPC::XML::Client;
#use Data::Dumper;

my $itemUpdate = <<END;
<xupdate:modifications version="1.0" xmlns:xupdate="http://www.xmldb.org/xupdate">
  <xupdate:insert-after select="//image[position()=1]" >
    <xupdate:element name="item">
      <xupdate:element name="title">TITULO</xupdate:element>
      <xupdate:element name="link">LINK</xupdate:element>
    </xupdate:element>
  </xupdate:insert-after>
</xupdate:modifications>
END

my $URL = 'http://dario@localhost:8080/exist/xmlrpc';

my $client = new RPC::XML::Client $URL;

my $options = RPC::XML::struct->new(
    'indent' => 'yes', 
    'encoding' => 'UTF-8',
    'highlight-matches' => 'none');

my $req = RPC::XML::request->new("xupdateResource", "/db/aap/rss/feed1022.xml", RPC::XML::base64->new($itemUpdate));
 
my $response = $client->send_request($req);

#print Dumper($response);